package com.dataseek.iot.toolkit.tenant.utils;

import com.dataseek.iot.toolkit.tenant.consts.TenantConsts;

//自定义工具类
public class CustomDBUtils {
    /**
     * 生成jdbc-url工具方法
     * @param dbType
     * @param host
     * @param port
     * @param databaseName
     * @param schemaName
     * @return
     */
    public static String generateJdbcUrl(String dbType,
                                         String host,
                                         Integer port,
                                         String databaseName,
                                         String schemaName
                                         ){
        String jdbcUrl = null;
        if(TenantConsts.DBTYPE_POSTGRESQL.equals(dbType)){
            jdbcUrl="jdbc:postgresql://"
                    +host
                    +":"
                    +port
                    +"/"
                    +databaseName
                    +"?currentSchema="
                    +schemaName;
        }
        else if(TenantConsts.DBTYPE_MYSQL.equals(dbType)){
            //TODO 拼接mysql相关数据库链接
        }
        return jdbcUrl;
    }
}
